<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
  </style>
</head>

<body>
  <script>
    // 10进制转化为二进制
    function TenTo2(num) {
      let final = ''
      loop() 
      final = '1' + final
      return final
      function loop() {
        while (Math.floor(num / 2) > 0) {
          final = num % 2 + final
          num = Math.floor(num / 2)
        }
      }
    }

    let num = TenTo2(15)
    console.log(num)
  </script>
</body>

</html>